<html>
<head><title>CS 143 Calculator</title></head>
<body>

<h1>CS143 Project 1A: PHP Calculator</h1>
Allison Le (#703698832)<br />
Type an calc in the following box (e.g., 10.5+20*3/25).
<p>
<form action="" method="get">
<input type="text" name="calc" />
<input type="submit" value="calculate" /><br /><br />
<?php if(isset($_GET['calc'])) {
	if(preg_match("/^(\-)?[0-9]+([*\-+\/]{1}(\-)?[0-9]+)*$/", $_GET['calc'], $matches) != 0) {
		echo "<h2>Result: </h2> " . $_GET['calc'] . " = ";
		eval('echo '.$_GET['calc'].';');
	}
	
	else
		echo "<strong>Error:</strong> Not a valid mathematical expression.";
} 
?></form>
</p>
</body>
</html>